var contentPath = $("#topNavCon").attr("value");

//����靝�嗘撈LOGO皛𡁜𢆡
var cooLogoListSwiper = new Swiper('.company-logo-contain',{
    watchSlidesProgress : true,
    watchSlidesVisibility : true,
    slidesPerView : 5,
    autoHeight: true,
    onTap: function(){
        cooIntroListSwiper.slideTo( cooLogoListSwiper.clickedIndex)
    }
});
//  ����靝�嗘撈����𡑒秩��擧�𡁜𢆡
var cooIntroListSwiper = new Swiper('.company-intro-contain',{
    prevButton:'#cooPrev',
    nextButton:'#cooNext',
    autoHeight: true,
    onSlideChangeStart: function(){
        updateNavPosition()
    }
});

$(function(){
    // �繮��� ����峕�鈭�
    getStory();

    setTimeout(function() {
        var swiper = new Swiper('#storyCar', {
            speed: 1000,
            autoplay: 3000,
            autoplayDisableOnInteraction : false,
            updateOnImagesReady : true,
            loop : true,
            effect : 'coverflow',
            slidesPerView: 3,
            centeredSlides: true,
            autoHeight: true,
            coverflow: {
                rotate: 30,
                stretch: 10,
                depth: 60,
                modifier: 2,
                slideShadows : true
            }
        });
        //  �揻隤㗇�穃𢆡
        var honorListSwiper = new Swiper('.honor-swiper', {
            slidesPerView: 3,
            spaceBetween : 15,
            updateOnImagesReady : true,
            prevButton:'#honorPrev',
            nextButton:'#honorNext',
        });
    },2000);


    setTimeout(function () {
        //  ����靝�嗘撈LOGO皛𡁜𢆡
        var cooLogoListSwiper = new Swiper('.company-logo-contain',{
            watchSlidesProgress : true,
            watchSlidesVisibility : true,
            updateOnImagesReady : true,
            slidesPerView : 5,
            onTap: function(){
                cooIntroListSwiper.slideTo( cooLogoListSwiper.clickedIndex)
            }
        });
        //  ����靝�嗘撈����𡑒秩��擧�𡁜𢆡
        var cooIntroListSwiper = new Swiper('.company-intro-contain',{
            prevButton:'#cooPrev',
            nextButton:'#cooNext',
            onSlideChangeStart: function(){
                updateNavPosition()
            }
        });

        //  ����靝�嗘撈LOGO��峕���𡑒�𥪜𢆡
        function updateNavPosition(){
            $('.company-logo-contain').find(".active-nav").removeClass('active-nav');
            var activeNav = $('.company-logo-contain').find(".logo-list").eq(cooIntroListSwiper.activeIndex).addClass('active-nav');
            if (!activeNav.hasClass('swiper-slide-visible')) {
                if (activeNav.index()>cooLogoListSwiper.activeIndex) {
                    var thumbsPerNav = Math.floor(cooLogoListSwiper.width/activeNav.width())-1;
                    cooLogoListSwiper.slideTo(activeNav.index()-thumbsPerNav)
                }
                else {
                    cooLogoListSwiper.slideTo(activeNav.index())
                }
            }
        }
    },2000);

});




//  ����靝�嗘撈LOGO��峕���𡑒�𥪜𢆡
function updateNavPosition(){
    $('.company-logo-contain').find(".active-nav").removeClass('active-nav');
    var activeNav = $('.company-logo-contain').find(".logo-list").eq(cooIntroListSwiper.activeIndex).addClass('active-nav');
    if (!activeNav.hasClass('swiper-slide-visible')) {
        if (activeNav.index()>cooLogoListSwiper.activeIndex) {
            var thumbsPerNav = Math.floor(cooLogoListSwiper.width/activeNav.width())-1;
            cooLogoListSwiper.slideTo(activeNav.index()-thumbsPerNav)
        }
        else {
            cooLogoListSwiper.slideTo(activeNav.index())
        }
    }
}




function getStory(){
    $.ajax({
        url:"getStory.do",
        type:"POST",
        data:{},
        success:function(data){
            data=eval("("+data+")");
            var story=data.story;
            if(story!=null ){
                // �����
                $("#story_title").html(story.title);
                var content = story.content;
                content = ReplaceAll(content,"_&", "<br>");
                $("#story_content").html(content);

                // 閫�憸煾曎�𦻖
                $("#video_id").attr("src", story.videoUrl);

                // 頧格偘�㦛
                var turnsList = data.turnsList;
                // var html1 = "";
                // for(var i=0; i<turnsList.length; i++){
                //     html1 += '<img class="swiper-slide swiper-no-swiping" src="'+turnsList[i].picUrl+'" alt="1"/>';
                // }
                // $("#turnspic").html(html1);

                // 隞瑕�潭�滚𦛚
                var html2 = "";
                var serviceTitleList = data.serviceTitleList;
                var serviceList = data.returnAllService;
                for(var i=0; i<serviceTitleList.length; i++){
                    html2 += '<div class="service-list"><h5 class="service-title">'+serviceTitleList[i].title+'</h5>';
                    html2 += '<div class="service-intro"><p>';
                    // 隞瑕�潭�滚𦛚 ��摰�
                    for(var j=0;j<serviceList.length; j++){
                        if(serviceTitleList[i].serviceTitleId == serviceList[j].serviceTitleId){
                            html2 += '繚'+serviceList[j].content+'<br>';
                        }
                    }
                    html2 += '</p></div></div>'
                }
                $("#service-contain").html(html2);

                // ����靝�嗘撈
                var html3 = "";// �㦛���
                var html4 = "";// �����
                var partnerList = data.partnerList;
                for(var i=0; i<partnerList.length; i++){
                    if(i==0){
                        html3 += '<div class="swiper-slide logo-list active-nav">';
                    }else{
                        html3 += '<div class="swiper-slide logo-list">';
                    }
                    html3 += '<img src="'+partnerList[i].picUrl+'" alt=""/>';
                    html3 += '<i class="line"></i><i class="triangle"></i></div>';
                    html4 += '<div class="swiper-slide intro-list"><div class="intro-content"><p>'+partnerList[i].content+'</p></div></div>';
                }
                $("#partner_pic").html(html3);
                $("#partner_content").html(html4);

                // �揻隤�
                var html5 = "";
                var honorList = data.honorList;
                for(var i=0; i<honorList.length; i++){
                    html5 += '<div class="swiper-slide honor-list">';
                    html5 += '<div class="img-contain">';
                    html5 += '<img src="'+honorList[i].picUrl+'" alt="">';
                    html5 += '</div>';
                    html5 += '<div class="text-contain">';
                    html5 += '<h5>'+honorList[i].title+'</h5>';
                    html5 += '<p>'+honorList[i].createTimeStr+'</p>';
                    html5 += '</div></div>';
                }
                $("#honor_list").html(html5);

                // ��鞉��
                var html6 = "";
                var localList = data.localList;
                for(var i=0; i<localList.length; i++){
                    html6 += '<div class="location-list">';
                    html6 += '<h5 class="location-name">'+localList[i].title+'</h5>';
                    html6 += '<div class="contact-method">'+localList[i].content;
                    html6 += '</div></div>';
                }
                $("#local").html(html6);


                //  ����靝�嗘撈LOGO皛𡁜𢆡
                var cooLogoListSwiper = new Swiper('.company-logo-contain',{
                    watchSlidesProgress : true,
                    watchSlidesVisibility : true,
                    updateOnImagesReady : true,
                    slidesPerView : 5,
                    onTap: function(){
                        cooIntroListSwiper.slideTo( cooLogoListSwiper.clickedIndex)
                    }
                });

            }

        },
    });
}



